package com.atguigu.guli.service.edu.controller.admin;

import com.atguigu.guli.service.base.result.R;
import com.atguigu.guli.service.edu.entity.Subject;
import com.atguigu.guli.service.edu.service.SubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequestMapping("/admin/edu/subject")
@Slf4j

@Api(tags = "课程管理模块")
public class AdminSubjectController {

    @Autowired
    SubjectService subjectService ;

    @ApiOperation("导入课程")
    @PostMapping("import")
    public R importSubject(MultipartFile file) {
        subjectService.importSubject(file) ;
        return R.ok() ;
    }

    //查询课程分类嵌套集合
    @ApiOperation("查询课程分类嵌套集合")
    @GetMapping("getNestedSubjects")
    public R getNestedSubjects() {
        List<Subject> pSubjects = subjectService.getNestedSubjects() ;
        return R.ok().data("items",pSubjects) ;
    }
}
